//
//  City.m
//  CarTown
//
//  Created by xionghao on 15/8/12.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "City.h"
#import "CityItem.h"
@implementation City
+(instancetype)citywithDict:(NSArray *)array{
    City *ctiy=[[City alloc]init];
    NSMutableArray *mprovince=[NSMutableArray array];
    NSMutableArray *mcity=[NSMutableArray array];
    NSMutableArray *mdist=[NSMutableArray array];
    if ([array isKindOfClass:[NSNull class]]) {
        for (NSDictionary *dict in array) {
            CityItem *item=[CityItem itemWithDict:dict];
            if ([item.area_type integerValue]==1) {
                [mprovince addObject:item];
            }else if([item.area_type integerValue]==2){
                [mcity addObject: item];
            }else if([item.area_type integerValue]==3)
            {
                [mdist addObject:item];
            }
        }

    }
    ctiy.province_array=mprovince;
    ctiy.cityarray=mcity;
    ctiy.districtsarray=mdist;
    return ctiy;
}
@end
